home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Unicode Reordering.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.2 KB  |  87 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20. short MyStrLen(char *x);
  21. static short MyStrLen(x)
  22. char    *x;
  23.     {
  24.     short c = 0;
  25.     while (*x++) c++;
  26.     return c;
  27.     }    /* MyStrLen */
  28.  
  29. void UnicodeReordering(WindowPtr sampleWindow)
  30.     {
  31.     /* Variables */
  32.     char            *myString = "ABCDEFGHIJ";
  33.     gxLayoutOptions    gxLayoutOptions;
  34.     gxPoint            myPoint;
  35.     gxRunControls        gxRunControls;
  36.     gxShape            layout;
  37.     short            i, len, level = 0, runLengths[5], runLevels[5];
  38.     gxStyle            reversedStyle, romanStyle, styleArray[5];
  39.     gxViewPort        aViewPort;
  40.     
  41.     /* Initialization */
  42.     
  43.     myPoint.x = ff(30);
  44.     myPoint.y = ff(50);
  45.     
  46.     aViewPort = GXNewWindowViewPort(sampleWindow);
  47.     SetDefaultViewPort(aViewPort);
  48.     
  49.     len = MyStrLen(myString);
  50.     for (i = 0; i < 5; i++) runLengths[i] = 2;
  51.     
  52.     romanStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  53.     
  54.     InitializeRunControls(&gxRunControls);
  55.     gxRunControls.flags = gxImposeRightToLeft;
  56.     reversedStyle = NewLayoutStyle(
  57.         (char *) "\pZapf Chancery Medium Italic", ff(50), 0, &gxRunControls, nil, 0, nil);
  58.     
  59.     styleArray[0] = styleArray[2] = styleArray[4] = romanStyle;
  60.     styleArray[1] = styleArray[3] = reversedStyle;
  61.     
  62.     layout = GXNewLayout(
  63.         1, &len, (void *) &myString,
  64.         5, runLengths, styleArray,
  65.         1, &len, &level,
  66.         nil, &myPoint);
  67.     GXDrawShape(layout);
  68.     
  69.     InitializeLayoutOptions(&gxLayoutOptions);
  70.     gxLayoutOptions.flags = gxImposeLeftToRight;
  71.     level = 1;
  72.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 1, &len,  &level,&gxLayoutOptions, nil);
  73.     GXMoveShape(layout, 0, ff(75));
  74.     GXDrawShape(layout);
  75.     
  76.     runLevels[0] = runLevels[4] = 0;
  77.     runLevels[1] = runLevels[2] = runLevels[3] = 1;
  78.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 5, runLengths, runLevels, nil, nil);
  79.     GXMoveShape(layout, 0, ff(75));
  80.     GXDrawShape(layout);
  81.     
  82.     GXDisposeShape(layout);
  83.     GXDisposeStyle(romanStyle);
  84.     GXDisposeStyle(reversedStyle);
  85.     GXDisposeViewPort(aViewPort);
  86.     }    /* main */
  87.